package simtools.wizard;

import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Rectangle;

import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;


import java.awt.Dimension;
import javax.swing.BorderFactory;
import javax.swing.border.TitledBorder;
import java.awt.Color;
import javax.swing.JCheckBox;
import java.awt.Point;

public class Dataset extends JInternalFrame {

	private static final long serialVersionUID = 1L;

	private JPanel jContentPane = null;

	private JTextField videoTextField = null;

	private JButton jButton = null;

	private JTextField requestsTextField = null;

	private JButton jButton1 = null;

	private JPanel jPanel4 = null;

	private JButton jButton11 = null;

	private JButton jButton2 = null;

	private JPanel jPanel = null;

	private JPanel jPanel1 = null;

	private JLabel jLabel = null;

	private JTextField jTextField = null;

	private JCheckBox jCheckBox = null;

	public static Dataset getInstance() {
		return DatasetHolder.instance;
	}
	
	private static class DatasetHolder {
        private static Dataset instance = new Dataset();
    }
	
	/**
	 * This is the default constructor
	 */
	public Dataset() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(406, 305);
		this.setClosable(true);
		this.setContentPane(getJContentPane());
		this.setTitle("Dataset");
		this.setResizable(false);
		Wizard.centralize(this);
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.setFont(new Font("Tahoma", Font.PLAIN, 11));
			jContentPane.add(getJPanel4(), null);
			jContentPane.add(getJPanel(), null);
			jContentPane.add(getJPanel1(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes videoTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getVideoTextField() {
		if (videoTextField == null) {
			videoTextField = new JTextField();
			videoTextField.setBounds(new Rectangle(15, 31, 252, 20));
		}
		return videoTextField;
	}

	/**
	 * This method initializes jButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButton() {
		if (jButton == null) {
			jButton = new JButton();
			jButton.setText("Open");
			jButton.setBounds(new Rectangle(272, 29, 63, 24));
			jButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					JFileChooser jFileChooser = new JFileChooser();  
					int status = jFileChooser.showOpenDialog(null);  
					if (status == JFileChooser.APPROVE_OPTION) { 
					  String selectedPath = jFileChooser.getSelectedFile().getAbsolutePath();
					  videoTextField.setText(selectedPath);
					}
				}
			});
		}
		return jButton;
	}

	/**
	 * This method initializes requestsTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getRequestsTextField() {
		if (requestsTextField == null) {
			requestsTextField = new JTextField();
			requestsTextField.setBounds(new Rectangle(15, 31, 252, 20));
		}
		return requestsTextField;
	}

	/**
	 * This method initializes jButton1	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButton1() {
		if (jButton1 == null) {
			jButton1 = new JButton();
			jButton1.setText("Open");
			jButton1.setBounds(new Rectangle(272, 29, 63, 24));
			jButton1.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					JFileChooser jFileChooser = new JFileChooser();  
					int status = jFileChooser.showOpenDialog(null);  
					if (status == JFileChooser.APPROVE_OPTION) { 
					  String selectedPath = jFileChooser.getSelectedFile().getAbsolutePath();
					  requestsTextField.setText(selectedPath);
					}
				}
			});
		}
		return jButton1;
	}

	/**
	 * This method initializes jPanel4	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanel4() {
		if (jPanel4 == null) {
			GridLayout gridLayout1 = new GridLayout();
			gridLayout1.setRows(1);
			gridLayout1.setHgap(10);
			jPanel4 = new JPanel();
			jPanel4.setLayout(gridLayout1);
			jPanel4.setBounds(new Rectangle(121, 231, 156, 26));
			jPanel4.add(getJButton11(), null);
			jPanel4.add(getJButton2(), null);
		}
		return jPanel4;
	}

	/**
	 * This method initializes jButton11	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButton11() {
		if (jButton11 == null) {
			jButton11 = new JButton();
			jButton11.setText("< Back");
			jButton11.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					Wizard.jDesktopPane.removeAll();
					Wizard.jDesktopPane.repaint();
					
					Wizard.internal = NetworkTopology.getInstance();
					Wizard.jDesktopPane.add(Wizard.internal);
					Wizard.internal.setVisible(true);
				}
			});
		}
		return jButton11;
	}

	/**
	 * This method initializes jButton2	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButton2() {
		if (jButton2 == null) {
			jButton2 = new JButton();
			jButton2.setText("Next >");
			jButton2.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					Wizard.jDesktopPane.removeAll();
					Wizard.jDesktopPane.repaint();
					
					Wizard.internal = Cache.getInstance();
					Wizard.jDesktopPane.add(Wizard.internal);
					Wizard.internal.setVisible(true);
				}
			});
		}
		return jButton2;
	}

	/**
	 * This method initializes jPanel	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanel() {
		if (jPanel == null) {
			jLabel = new JLabel();
			jLabel.setBounds(new Rectangle(15, 70, 71, 20));
			jLabel.setText("Bit Rate (kbps)");
			jPanel = new JPanel();
			jPanel.setLayout(null);
			jPanel.setBounds(new Rectangle(15, 16, 363, 111));
			jPanel.setBorder(BorderFactory.createTitledBorder(null, "Video Objects", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", Font.PLAIN, 11), new Color(0, 70, 213)));
			jPanel.add(getVideoTextField(), null);
			jPanel.add(getJButton(), null);
			jPanel.add(jLabel, null);
			jPanel.add(getJTextField(), null);
			jPanel.add(getJCheckBox(), null);
		}
		return jPanel;
	}

	/**
	 * This method initializes jPanel1	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanel1() {
		if (jPanel1 == null) {
			jPanel1 = new JPanel();
			jPanel1.setLayout(null);
			jPanel1.setBounds(new Rectangle(14, 140, 362, 75));
			jPanel1.setBorder(BorderFactory.createTitledBorder(null, "Requests", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", Font.PLAIN, 11), new Color(0, 70, 213)));
			jPanel1.add(getRequestsTextField(), null);
			jPanel1.add(getJButton1(), null);
		}
		return jPanel1;
	}

	/**
	 * This method initializes jTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextField() {
		if (jTextField == null) {
			jTextField = new JTextField();
			jTextField.setPreferredSize(new Dimension(30, 20));
			jTextField.setLocation(new Point(91, 70));
			jTextField.setSize(new Dimension(41, 20));
			jTextField.setEnabled(false);
			jTextField.setText("300");
		}
		return jTextField;
	}

	/**
	 * This method initializes jCheckBox	
	 * 	
	 * @return javax.swing.JCheckBox	
	 */
	private JCheckBox getJCheckBox() {
		if (jCheckBox == null) {
			jCheckBox = new JCheckBox();
			jCheckBox.setBounds(new Rectangle(149, 70, 140, 21));
			jCheckBox.setText("Default");
			jCheckBox.addItemListener(new java.awt.event.ItemListener() {
				public void itemStateChanged(java.awt.event.ItemEvent e) {
					if (jCheckBox.isSelected()) {
						jTextField.setEnabled(true);
					} else {
						jTextField.setEnabled(false);
					}
				}
			});
		}
		return jCheckBox;
	}

}  //  @jve:decl-index=0:visual-constraint="10,10"
